﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace FineSoft.Models
{
	public class Class
	{
		public int Index;
		public bool Private;
		public virtual string Name { get; set; }
		public string Description;

		public static Class CustomCode = new Class
		{
			Private=true,
			Name="CustomCode",
			Description = "Set the config value to a custom code."
		};

		private static ComponentClass _AbstractContainer;
		public static ComponentClass AbstractContainer
		{
			get
		    {
				if (_AbstractContainer == null)
					_AbstractContainer = (ComponentClass)InitialData.GetClass("Ext.container.AbstractContainer");
				return _AbstractContainer;
		    }
		}

		private static Class _String;
		public static Class String
		{
			get
			{
				if (_String == null)
					_String = InitialData.Classes.First(c => c.Name == "String");
				return _String;
			}
		}

		private static Class _Number;
		public static Class Number
		{
			get
			{
				if (_Number == null)
					_Number = InitialData.Classes.First(c => c.Name == "Number");
				return _Number;
			}
		}

		private static Class _Date;
		public static Class Date
		{
			get
			{
				if (_Date == null)
					_Date = InitialData.Classes.First(c => c.Name == "Date");
				return _Date;
			}
		}

		private static Class _Boolean;
		public static Class Boolean
		{
			get
			{
				if (_Boolean == null)
					_Boolean = InitialData.Classes.First(c => c.Name == "Boolean");
				return _Boolean;
			}
		}

		private static Class _Object;
		public static Class Object
		{
			get
			{
				if (_Object == null)
					_Object = InitialData.Classes.First(c => c.Name == "Object");
				return _Object;
			}
		}

		private static Class _Function;
		public static Class Function
		{
			get
			{
				if (_Function == null)
					_Function = InitialData.Classes.First(c => c.Name == "Function");
				return _Function;
			}
		}

		private static Class[] _NativeClasses;
		public static Class[] NativeClasses
		{
			get
			{
				if (_NativeClasses == null)
					_NativeClasses = new[] { String, Number, Date, Boolean };
				return _NativeClasses;
			}
		}
	}
}